library Wave8 initializer init requires LegacySystem

    globals
        private trigger HadesPullPeriodicTrigger
        private trigger MoiraeDeadTrigger
        private trigger MoiraeInfectionTrigger
        private trigger MoriaeAtrien12Trigger
        private trigger MoiraeTrackerTrigger
		private sound theMusic1 = null
		private sound theMusic2 = null
		
    endglobals
	
	private function PlayWave8RegularMusic takes boolean b returns nothing
		local integer i = 10
		local integer j = 100
		
		if theMusic1 == null then
			set theMusic1 = CreateSound("Sound\\Music\\mp3Music\\Undead1.mp3", false, false, false, 10, 10, "DefaultEAXON")
			call SetSoundChannel(theMusic1,3)
		endif
		
		if b then
			call SetSoundVolume(theMusic1, 127)
			call StartSound(theMusic1)
		else
			set i = 10
			loop
				exitwhen 0 > i 
				call TriggerSleepAction(2.5)
				call SetSoundVolume(theMusic1, j)
				set j = j - 10
				set i = i - 1
			endloop
			call StopSound(theMusic1,false, true)
		endif	
	endfunction
	
	private function PlayWave8DarkCloudMusic takes boolean b returns nothing
		local integer i = 10
		local integer j = 100
		
		if theMusic2 == null then
			set theMusic2 = CreateSound("Sound\\Music\\mp3Music\\Undead3.mp3", false, false, false, 10, 10, "DefaultEAXON")
			call SetSoundChannel(theMusic2,3)
		endif
		
		if b then
			call SetSoundVolume(theMusic2, 127)
			call StartSound(theMusic2)
		else
			set i = 10
			loop
				exitwhen 0 > i 
				call TriggerSleepAction(2.5)
				call SetSoundVolume(theMusic2, j)
				set j = j - 10
				set i = i - 1
			endloop
			call StopSound(theMusic2,false, true)
		endif	
	endfunction
	
    private function MoiraeDead takes nothing returns nothing
        local integer i = udg_Minute - udg_DMKills[10]
        local integer i2 = udg_Second - udg_DMKills[20]
        local integer i3
        if i<0 then
            set i = 60+i
        endif
        if i2<0 then
            set i2 = 60+i2
        endif
        set i3 = i*60+i2
        call DisableTrigger(GetTriggeringTrigger())
        call DisableTrigger(MoiraeTrackerTrigger)
        call SetProximitySpawnEnabled(false)
        call StartSound(gg_snd_MoiraeDeath)
        set udg_IntenseSpawn = 0
        if i3<300 and udg_Mode==1 then
            set i = 1
            call ALICEText(10.0, "Moirae killed under five minutes. |cff1e90ff60 XP|r awarded to all Marines." )
            loop
                exitwhen i>udg_InitialPlayers
                if GetPlayerSlotState(ConvertedPlayer(udg_Sorted[i]))!=PLAYER_SLOT_STATE_LEFT then
                    set udg_Experience[udg_Sorted[i]] = udg_Experience[udg_Sorted[i]] + 60
                endif
                set i=i+1
            endloop
        endif
        call PolledWait(10.)
		call PlayWave8RegularMusic.execute(false)
        if udg_CurrentWave==8 then
            call ExecuteRegisteredFunction("Wave9a")
            //call Wave9a.execute()
        endif
    endfunction

    private function MoiraeAttackConditions takes nothing returns boolean
        return GetUnitTypeId(GetKillingUnit())=='U008'
    endfunction

    private function MoiraeAttack takes nothing returns nothing
        call DisableTrigger(GetTriggeringTrigger())
        call DisableTrigger(MoriaeAtrien12Trigger)
        call UnitRemoveAbility(udg_Boss,'B00U')
        call UnitAddAbility(udg_Boss,'A065')
        call DisplayTimedTextToPlayer( GetLocalPlayer(), 0.0, 0.0, 5.0, "Moirae has been infected with Atrien 12." )
        call PolledWait(12.)
        call GeneralText(10.0, "|cffcd950cMajor Grimes|r : I know it must have been a tough decision. But it's the right one. This conversation never took place. Semper Fi." )
        set udg_XPFactor=udg_XPFactor*0.9
        call PolledWait(5.)
        call ALICEText(5.0, "|cffcd950cALICE|r : Channel closed. Communications logs erased. OpSec Article 7 invoked." )
    endfunction

    private function Atrien12Conditions takes nothing returns boolean
        return GetSpellAbilityId()=='A064'
    endfunction

    private function Atrien12 takes nothing returns nothing
        local unit u = GetSpellTargetUnit()
        call TriggerRegisterUnitEvent(MoiraeInfectionTrigger,u,EVENT_UNIT_DEATH)
        set u = null
    endfunction

    private function MoiraeTracker takes nothing returns nothing
        local real x = GetUnitX(udg_Boss)
        local real y = GetUnitY(udg_Boss)
        if GetRandomInt(0,15)==1 and udg_SentryMission==-1 then
            set udg_SentryMission = 5
            call ALICEText(5.0, "|cffcd950cALICE|r : Tracking capabilities are temporarily disabled due to EM interference." )
        elseif udg_SentryMission>1 then
            set udg_SentryMission = udg_SentryMission - 1
            if udg_SentryMission==0 then
                set udg_SentryMission = -1
                call ALICEText(5.0, "|cffcd950cALICE|r : Tracking capabilities restored." )
            endif
        else
            call PingMinimapEx(x,y,2.5,255,0,0,false)
            call SetCameraQuickPosition(x,y)
            call StartSound(gg_snd_HeartBeat)
        endif
        set udg_DMKills[30] = udg_DMKills[30] + 1
        if udg_DMKills[30]==60 then
            call ShiftMoveSpeed(udg_Boss,200.0)
            call ExecuteRegisteredFunction("Wave9a")
            //call Wave9a.execute()
        endif
    endfunction

    private function SnatchChatter takes player p returns nothing
        call GeneralText(1.25, "|cffcd950cMarine|r : What the hell was that sound? " + GetPlayerName(p) + " is missing!" )
        call PolledWait(2.)
        call GeneralText(1.0, "|cffcd950cMarine #2|r : I don't like this. Stay in visual range." )
        call PolledWait(2.)
        call GeneralText(1.25, "|cffcd950cMarine|r :" + GetPlayerName(p) + "!" )
    endfunction

    private function Snatch takes nothing returns nothing
        local real x
        local real y
        local real theta
        local real dx
        local real dy
        local integer i = 20
        local item it
        local player p
        if udg_Players<1 then
            call DisableTrigger(GetTriggeringTrigger())
            return
        endif
        set udg_SnatchTarget = udg_Hero[udg_Sorted[GetRandomInt(1,udg_Players)]]
        set p = GetOwningPlayer(udg_SnatchTarget)
        if getBoolean(udg_SnatchTarget,"jumping")==true then
            call PolledWait(1.5)
        endif
        set x = GetUnitX(udg_SnatchTarget)
        set y = GetUnitY(udg_SnatchTarget)
        call SetUnitAnimation(udg_SnatchTarget,"death")
        call IssueImmediateOrder(udg_SnatchTarget,"stop")
        call PauseUnit(udg_SnatchTarget,true)
        call DestroyEffect(AddSpecialEffect( "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", x, y ))
        set theta = Atan2(GetUnitY(udg_Boss) - y, GetUnitX(udg_Boss) - x)
        set dx = Cos(theta)
        set dy = Sin(theta)
        loop
            exitwhen i>525
            call DestroyEffect(AddSpecialEffect( "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", x + i * dx, y + i * dy))
            if GetRandomInt(0,2)==1 then
                call TriggerSleepAction(0.)
            endif
            set i=i+35
        endloop
        //call TerrainDeformCrater(x, y, 150.0, 80.0, 3000, true)
        call StartSound(gg_snd_BlackHawkLand)
        call PolledWait(0.6)
        if udg_SquadXP>37500 then
            set i = GetRandomInt(0,5)
            set it = UnitItemInSlot(udg_SnatchTarget,i)
            // note, nano does not count as armor O_o (original code)
            if GetItemTypeId(it)!='I00Z' and GetItemTypeId(it)!='I001' and GetItemTypeId(it)!='I005' and GetItemTypeId(it)!='rde1' then //not armor
                call UnitRemoveItemFromSlot(udg_SnatchTarget,i)
            endif
        endif
        call IssueImmediateOrder(udg_Boss,"stop")
        call SetUnitPosition( udg_SnatchTarget, GetUnitX(udg_Boss)+GetRandomReal(-10.0,10.0), GetUnitY(udg_Boss)+GetRandomReal(-10.0,10.0) )
        set x = GetUnitX(udg_SnatchTarget)
        set y = GetUnitY(udg_SnatchTarget)
        if GetLocalPlayer()==p then
            call PanCameraToTimed(x,y,0.0)
        endif
        call DestroyEffect(AddSpecialEffect( "Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", x, y ))
        //call TerrainDeformCrater(x, y, 150.0, 80.0, 3000, true)
        call UnitDamageTarget(udg_Boss,udg_SnatchTarget,120.0,true,false,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        call PauseUnit(udg_SnatchTarget,false)
        call PolledWait(0.25)
        call ResetUnitAnimation(udg_SnatchTarget)
        call PauseUnit(udg_SnatchTarget,false)
        if udg_GlobalBoolean[4]==false and udg_Players>2 then
            set udg_GlobalBoolean[4] = true
            call SnatchChatter(p)
        endif
        set it=null
    endfunction



    private function Wave8bPeriodicSpawn takes nothing returns nothing
        call RandomSpawn('ndwm',2, GetRandomInt(0,2*udg_Spawn) ) //Parasite
        call RandomSpawn('nsw1',2,GetRandomInt(1,udg_Spawn)) //Stalker
        call RandomSpawn('ugar',1,GetRandomInt(0,udg_Spawn)) //Gargolye
        call GankMarine(Player(14),'nzom',1+GetRandomInt(1, udg_Spawn),900,1500)
        if udg_CurrentWave!=8 then
            call DisableTrigger(GetTriggeringTrigger())
        endif
    endfunction

    private function SnatcherAI takes nothing returns nothing
        local location l = GetRandomLocInRect(bj_mapInitialPlayableArea)
        if GetWidgetLife(udg_Boss)>0.405 then
            if udg_SquadXP>40000 and GetRandomInt(0,2)==1 then
                call IssuePointOrderLoc(udg_Boss,"attack",l)
            else
                call IssuePointOrderLoc(udg_Boss,"move",l)
            endif
            if GetRandomInt(1,10)==1 then
                set udg_soundpath = "Sound\\Dialogue\\NightElfCampaign\\NightElf01\\N01Archimonde30.mp3"
                call PlaySoundPath.execute()
            endif
        else
            call DisableTrigger(GetTriggeringTrigger())
        endif
        call RemoveLocation(l)
        set l = null
    endfunction

    private function SnatcherKilled takes nothing returns nothing
        call DisableTrigger(GetTriggeringTrigger())
        call DisableTrigger(HadesPullPeriodicTrigger)
        if GetRandomInt(0,1)==1 then
            call GeneralText(3.0, "|cffcd950cMarine|r : We've killed it. Ping positions and regroup." )
        else
            call GeneralText(3.0, "|cffcd950cMarine|r : That was one ugly motherfucker. Regroup!" )
        endif
        call PolledWait(15.)
        call SetAINeutralVictimEnabled(true)
		
 
        if udg_FuelEfficiency[777]==1337 then
            call ExecuteRegisteredFunction("Wave9c")
			// music continues to wave 9 since its DC
			// call Wave9c.execute()
        else
			call PlayWave8RegularMusic.execute(false)
            call ExecuteRegisteredFunction("Wave9a")
            //call Wave9a.execute()
        endif
    endfunction


    private function Wave8c takes nothing returns nothing
        local integer i = 1
        local integer diablofactor = 75
        local trigger t = CreateTrigger()
        local location l = GetRandomLocInRect(udg_PlayerSpawnBoundary)
		
		call PlayWave8DarkCloudMusic.execute(true)
        set udg_CurrentWave = 8
        call GenericActions.execute()
        set udg_FuelEfficiency[777] = 1337
        call SetAINeutralVictimEnabled(false)

        if udg_SquadXP>40000 then
           set diablofactor = 20
        endif
        if udg_InitialPlayers>2 and GetRandomInt(0,diablofactor)==1 then
            set udg_Boss = CreateUnitAtLoc(Player(13),'U00J',l,0) //Diablo
        else
            set udg_Boss = CreateUnitAtLoc(Player(13),'U00H',l,0) //Hades
        endif
        call TriggerRegisterTimerEvent(HadesPullPeriodicTrigger,35.0,true)
        call TriggerRegisterUnitEvent( t, udg_Boss, EVENT_UNIT_DEATH )
        call TriggerAddAction( t, function SnatcherKilled )
        set t = CreateTrigger()
        call TriggerRegisterTimerEvent( t, 8.0,true )
        call TriggerAddAction( t, function SnatcherAI )
        set t = null
        call SuspendHeroXP(udg_Boss,true)
        call RemoveLocation(l)
        set l = null
        call StartSound(gg_snd_MoiraeDeath)
        call PolledWait(5.)
        set i = GetRandomInt(1, udg_Players)
        call FieldChat(udg_Hero[udg_Sorted[i]], 5.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r : Anyone else heard that?" )
        call PolledWait(5.)
        call LightningAmbience.execute()
        call PolledWait(2.5)
        set i = GetRandomInt(1, udg_Players)
        call FieldChat(udg_Hero[udg_Sorted[i]], 5.0, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r : Whatever it is, it's coming this way." )
        call PolledWait(8.0*udg_Pace)
        call StartSound(udg_Ambience[1])
        call PolledWait(80.0*udg_Pace)
        call StartSound(udg_Ambience[2])
        call PolledWait(8.0*udg_Pace)
        call StartSound(udg_Ambience[1])
    endfunction

	
    private function Wave8b takes nothing returns nothing
        local location l = GetRandomLocInRect(udg_PlayerSpawnBoundary)
        local trigger t = CreateTrigger()
        local integer i
        local integer diablofactor=50
        local real x
        local real y
        local real dx
        local real dy
        local real snatchtime=40.0
		
		call PlayWave8RegularMusic.execute(true)

        loop
            set x = GetLocationX(l)
            set y = GetLocationY(l)
            set dx = x-GetUnitX(udg_Residence41)
            set dy = y-GetUnitY(udg_Residence41)
            exitwhen dx*dx+dy*dy>6250000.0 //2500 radius
            call RemoveLocation(l)
            set l = GetRandomLocInRect(udg_PlayerSpawnBoundary)
        endloop
        set udg_CurrentWave = 8
        call TriggerRegisterTimerEventPeriodic(t,45.0)
        call TriggerAddAction( t, function Wave8bPeriodicSpawn )
        call GenericActions.execute()
        
        call SetAINeutralVictimEnabled(false)

        call PolledWait(10.0*udg_Pace)
        if udg_SquadXP>40000 then
            set diablofactor=15
        endif
        if udg_SquadXP>50000 then
            set snatchtime=22.0
        endif
        if udg_InitialPlayers>2 and GetRandomInt(1,50)==1 then
            set udg_Boss = CreateUnit(Player(13),'U00J',x,y,0.0) // Diablo
            call TriggerRegisterTimerEvent(HadesPullPeriodicTrigger,snatchtime,true)
        elseif udg_Players<4 then
            set udg_Boss = CreateUnit(Player(13),'U00H',x,y,0.0)
            call TriggerRegisterTimerEvent(HadesPullPeriodicTrigger,snatchtime,true)
        else
            set udg_Boss = CreateUnit(Player(13),'U00I',x,y,0.0)
            call TriggerRegisterTimerEvent(HadesPullPeriodicTrigger,snatchtime,true)
        endif
        call SuspendHeroXP(udg_Boss,true)

        set t = CreateTrigger()
        call TriggerRegisterUnitEvent( t, udg_Boss, EVENT_UNIT_DEATH )
        call TriggerAddAction( t, function SnatcherKilled )

        set t = CreateTrigger()
        call TriggerRegisterTimerEvent( t, 8.0,true )
        call TriggerAddAction( t, function SnatcherAI )
        set t = null

        call RemoveLocation(l)
        set l = null
        call PolledWait(25.0*udg_Pace)
        call RandomSpawn('u000',2,GetRandomInt(0, udg_Spawn)) //Futty
        call PolledWait(15.0*udg_Pace)
        if GetRandomInt(0,20)==1 then
            call GankMarine(Player(13),'n00W',2+udg_Spawn,1800,3500)
            call GankMarine(Player(13),'n00W',2+udg_Spawn,1800,3500)
        endif
        if GetWidgetLife(udg_Boss)<=0.405 then
            return
        endif
        call MultiboardSetTitleText( udg_SquadStatus, "Hunt the Unknown Threat" )
        call MBSet( udg_SquadStatus, 1, 1, "Objective : Hunt the Unknown Threat" )
        call QuestSetDescription(udg_CurrentOrders, "An unidentified creature has been spotted. Keep your squad alive and learn as much as you can about it." )
        call ALICEText(5.0, "|cff8b864eNew Objective|r : Hunt the Unknown Threat." )
        call MissionUpdate.execute()
        call PolledWait(3.)
        set i = GetRandomInt(1, udg_Players)
        call FieldChat(udg_Hero[udg_Sorted[i]], 5, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r : I'm not going down without a fight." )
        call PolledWait(6.)
        set i = GetRandomInt(1, udg_Players)
        call FieldChat(udg_Hero[udg_Sorted[i]], 5, udg_Pcolors[udg_Sorted[i]] + GetPlayerName(ConvertedPlayer(udg_Sorted[i])) + "|r : Go ahead, make my day." )
    endfunction

    private function Wave8a takes nothing returns nothing
        local integer i = 1
        local integer A = GetRandomInt(0,1)
        local integer B = GetRandomInt(0,1)
        local integer C = GetRandomInt(0,1)
        local integer atriendrop = 0
        local unit u
        local real x1
        local real y1
        local real x2
        local real y2
        local real avgxp = 0.0
		call PlayWave8RegularMusic.execute(true)
				
        set udg_CurrentWave = 8
        set udg_SentryMission = -1
        call GenericActions.execute()
        call RandomSpawn('n002',1,GetRandomInt(1,udg_Spawn)) //Devourer
        call RandomSpawn('n00N',1,GetRandomInt(0,2)) //Mass HP Zombie
        call SpawnRectRandom(gg_rct_SpawnEastCave,Player(14),'nzom',2+udg_Spawn)
        call SpawnRectRandom(gg_rct_SpawnEastBottom,Player(13),'n003',udg_Spawn)
        call SpawnRectRandom(gg_rct_SpawnNorthWaterfall,Player(14),'nsw1',udg_Spawn)
        call SpawnRectRandom(gg_rct_SpawnSouthWaterfall,Player(14),'u000',2+udg_Spawn)
        call SpawnRectRandom(gg_rct_SpawnSouthWaterfall,Player(13),'n003',udg_Spawn)
        call SpawnRectRandom(gg_rct_SpawnWestTop,Player(14),'u000',2+udg_Spawn)
        call PolledWait(3.0)
        set udg_myloc = GetRandomLocInRect(udg_PlayerSpawnBoundary)
        set udg_Boss = CreateUnitAtLoc(Player(14),'U008',udg_myloc,0)
        call SuspendHeroXP(udg_Boss, true)
        set udg_DMKills[10] = udg_Minute
        set udg_DMKills[20] = udg_Second
        set udg_DMKills[30] = 0
        call TriggerRegisterUnitEvent( MoiraeDeadTrigger, udg_Boss, EVENT_UNIT_DEATH )
        call TriggerRegisterAnyUnitEventBJ( MoriaeAtrien12Trigger, EVENT_PLAYER_UNIT_SPELL_CAST )
        call RemoveLocation(udg_myloc)
        if udg_SquadXP>30000 then
            call RandomSpawn('e00Q',2,udg_Spawn) // Parasite Mound
        endif
        call PolledWait(3.8)
        call TriggerRegisterTimerEvent(MoiraeTrackerTrigger, 10.0, true)
        call ALICEText(5.0, "|cffcd950cALICE|r : Detecting Moirae class entity. GPS tracking enabled." )
        call PolledWait(12.0*udg_Pace)
        call GeneralText(2.0, "|cfff3ad00Marine|r : I have a bad feeling about this." )
        call PolledWait(5.)
        set udg_soundpath = "Abilities\\Spells\\Orc\\Voodoo\\BigBadVoodooSpellBirth1.wav"
        call PlaySoundPath.execute()
        call PolledWait(10.0*udg_Pace)
        call GeneralText(6.0, "|cfff3ad00Marine|r : It was in Alpha Company's after-action report this week. Lost an entire rifle platoon to one of those things." )
        call PolledWait(12.0*udg_Pace)
        call RandomSpawn('n00C',1,udg_Players)
        call PolledWait(10.0*udg_Pace)
        call MultiboardSetTitleText( udg_SquadStatus, "Neutralize Moirae" )
        call MBSet( udg_SquadStatus, 1, 1, "Objective : Neutralize Moirae" )
        call QuestSetDescription(udg_CurrentOrders, "Moirae posses an immediate threat to your squad. It is highly resistant to conventional arms. Our science team recommends that you use heavy explosives or electromagnetic waves on it." )
        call ALICEText(5.0, "|cff8b864eNew Objective|r : Neutralize Moirae." )
        call MissionUpdate.execute()
        call SetProximitySpawnEnabled(true)
        call PolledWait(60.0*udg_Pace)
        set i=1
        loop
            exitwhen i>udg_InitialPlayers
            set avgxp = ((avgxp*(I2R(i)-1.0))+udg_Experience[udg_Sorted[i]])/I2R(i)
            set i=i+1
        endloop
        // call EnableTrigger(gg_trg_XML9C)
        if avgxp<=30000.0 or GetRandomInt(0,3)==1 then
            set udg_soundpath = "Sound\\Interface\\GlueScreenMeteorLaunch3.wav"
            call PlaySoundPath.execute()
            call PolledWait(6.)
            set x1 = GetRandomReal(-4000.0,9000.0)
            set y1 = GetRandomReal(-4000.0,9000.0)
            call CreateItem( 'I00H', x1, y1 )
            call GeneralText(7.0, "|cfff3ad00Battalion|r : XML-9C Tactical Nuke has been airdropped. Check your tactical map for coordinates. Over." )
            call PingMinimapEx(x1,y1,60.0,255,0,0,false)
            call SetCameraQuickPosition(x1,y1)
            call PolledWait(5.)
            call GeneralText(6.0, "|cfff3ad00Marine|r : The XML-9C? Has it been tested? Over." )
            call PolledWait(5.)
            call GeneralText(6.0, "|cfff3ad00Battalion|r : We ran field tests in Nevada a few weeks back. It's not pretty, but it may be the only way to take Moirae out. We can't lose Sector E. Out." )
            call PolledWait(6.)
            call GeneralText(6.0, "|cfff3ad00Marine #2|r : What the hell's so important about this place? Can't believe we're going to use a tac nuke on our own soil." )
            return
        endif
        if udg_SquadXP>50000 and GetRandomInt(0,1)==1 then
            return
        endif
        if GetWidgetLife(udg_Boss)>0.405 then
            call ALICEText(3.0, "|cffcd950cALICE|r : Incoming Secure Channel. Decrypting.." )
        else
            return
        endif
        call PolledWait(5.)
        if GetWidgetLife(udg_Boss)>0.405 then
            call GeneralText(6.0, "|cffcd950cMajor Grimes|r : Third Platoon, you're in a tight predicament here. I want to help you out." )
        endif
        call PolledWait(5.)
        if GetWidgetLife(udg_Boss)>0.405 then
            call GeneralText(4.0, "|cffcd950cMarine|r : We're listening, Major. Over." )
        endif
        call PolledWait(5.)
        if GetWidgetLife(udg_Boss)>0.405 then
            call GeneralText(7.0, "|cffcd950cMajor Grimes|r : We've recently developed a virus that packs enough punch to kill a Moirae. It's not yet complete and the virus can only cultivate in a human body right now. You'll have to deliver it to Moirae with a human host. Over." )
        endif
        call PolledWait(5.)
        if GetWidgetLife(udg_Boss)>0.405 then
            call GeneralText(5.0, "|cffcd950cMarine|r : We can't do that, Sir. Over." )
        endif
        call PolledWait(3.)
        if GetWidgetLife(udg_Boss)>0.405 then
            call GeneralText(8.0, "|cffcd950cMajor Grimes|r : I don't think you UNDERSTAND me. Battalion hasn't briefed you on what's really at stake here. Collect the canisters from our men. You'll find the coordinates in your tac map. Out." )
        else
            return
        endif
        if A==1 then //NE
            set atriendrop = atriendrop + 1
            set x1 = 9400.0
            set y1 = 16000.0
        endif
        if B==1 then //SE
            set atriendrop = atriendrop + 1
            if atriendrop==1 then
                set x1 = 13150.0
                set y1 = -6000.0
            else
                set x2 = 13150.0
                set y2 = -6000.0
            endif
        endif
        if atriendrop<2 and C==1 then //NW
            set atriendrop = atriendrop + 1
            if atriendrop==1 then
                set x1 = -8200.0
                set y1 = 15700.0
            else
                set x2 = -8200.0
                set y2 = 15700.0
            endif
        endif
        if atriendrop<2 then //SW
            set atriendrop = atriendrop + 1
            set x2 = -6400.0
            set y2 = -6100.0
            if atriendrop==1 then
                set x1 = 9400.0
                set y1 = 16000.0
            endif
        endif
        set u = CreateUnit(Player(11),'z008',x1+50.0,y1-50.0,0.0)
        call SetLoadState(I2S(GetHandleId(u)),1)
        call UnitRemoveAbility(u,'A04N')
        call TriggerSleepAction(0.)
        set u = CreateUnit(Player(11),'z008',x2+50.0,y2-50.0,0.0)
        call SetLoadState(I2S(GetHandleId(u)),1)
        call UnitRemoveAbility(u,'A04N')
        set u = null
        call CreateItem('I012',x1,y1)
        call TriggerSleepAction(0.)
        call CreateItem('I012',x2,y2)
        call PingMinimapEx(x1,y1, 15.00, 77, 166, 153, true)
        call PingMinimapEx(x2,y2, 15.00, 77, 166, 153, true)
        call SetCameraQuickPosition(x1,y1)
        call SetCameraQuickPosition(x2,y2)
        call PolledWait(5.)
        if GetWidgetLife(udg_Boss)>0.405 then
            call GeneralText(5.0, "|cffcd950cMarine|r : We're not going to do that. It's fucking wrong." )
        endif
    endfunction

    private function init takes nothing returns nothing
        local trigger t
        set t = CreateTrigger()
        call TriggerAddAction(t,function Snatch)
        set HadesPullPeriodicTrigger = t
        
        set t = CreateTrigger()
        call TriggerAddAction(t,function MoiraeDead)
        set MoiraeDeadTrigger = t
        
        set t = CreateTrigger()
        call TriggerAddCondition( t, Condition( function MoiraeAttackConditions ) )
        call TriggerAddAction(t,function MoiraeAttack)
        set MoiraeInfectionTrigger = t
        
        set t = CreateTrigger()
        call TriggerAddCondition(t,Condition(function Atrien12Conditions))
        call TriggerAddAction(t, function Atrien12)
        set MoriaeAtrien12Trigger = t
        
        set t = CreateTrigger()
        call TriggerAddAction(t,function MoiraeTracker)
        set MoiraeTrackerTrigger = t
        
        call RegisterFunction("Wave8c", function Wave8c)
        call RegisterFunction("Wave8b", function Wave8b)
        call RegisterFunction("Wave8a", function Wave8a)
    endfunction

endlibrary